<template>
  <div class="user-page">
    <div class="user">
      <img
        :src="userinfo.avatar"
        alt=""
      />
      <h3>{{userinfo.account}}</h3>
      <van-icon name="edit" color="#80DDCD" class="edit"/>
      <div class="my_list">
        <div class="list">
          <p class="zero">{{userinfo.collectionNumber}}</p>
          <p class="gray">收藏</p>
        </div>
        <div class="list">
          <p class="zero">{{userinfo.likeNumber}}</p>
          <p class="gray">关注</p>
        </div>
        <div class="list">
          <p class="zero">{{userinfo.score}}</p>
          <p class="gray">积分</p>
        </div>
        <div class="list">
          <p class="zero">{{userinfo.couponNumber}}</p>
          <p class="gray">优惠券</p>
        </div>
      </div>
    </div>
    <!-- 问诊中 -->
    <div class="doctor">
      <van-swipe class="my-swipe"  :autoplay="3000" indicator-color="#2EB6A6" >
        <van-swipe-item v-for="(item,index) in list" :key="index">
          <h4>问诊中</h4>
          <div class="contentbox">
            <img :src="item.avatar" alt="">
            <div class="middle">
              <div class="top"><span class="lefttxt">{{item.name}}</span><span class="righttxt">{{item.depName}} | {{item.positionalTitles}}</span></div>
              <div class="bottom"><span class="lefttxt">{{item.gradeName}}</span><span class="righttxt">{{item.hospitalName}}</span></div>
            </div>
            <button>进入咨询</button>
          </div>
        </van-swipe-item>
      </van-swipe>
    </div>
    <!-- 药品订单 -->
    <van-cell-group class="mt20" :border="border">
      <van-cell
        title="药品订单"
        is-link
        class="mt21"
        value="全部订单"
        value-class="all"
      />
    </van-cell-group>
    <div class="views">
      <van-grid :border="border" icon-size="40px" class="views">
      <van-grid-item :icon="require('@/assets/icons/user/paid.svg')"  text="待付款" :badge="userinfo.orderInfo?.paidNumber===0?'':userinfo.orderInfo?.paidNumber" >
      </van-grid-item>
      <van-grid-item :icon=" require('@/assets/icons/user/shipped.svg')"  text="待发货" :badge="userinfo.orderInfo?.receivedNumber===0?'':userinfo.orderInfo?.receivedNumber" >
      </van-grid-item>
      <van-grid-item :icon=" require('@/assets/icons/user/received.svg')"  text="待收货" :badge="userinfo.orderInfo?.shippedNumber===0?'':userinfo.orderInfo?.shippedNumber" >
      </van-grid-item>
      <van-grid-item :icon=" require('@/assets/icons/user/finished.svg')"  text="待付款"  :badge="userinfo.orderInfo?.finishedNumber===0?'':userinfo.orderInfo?.finishedNumber" >
      </van-grid-item>
    </van-grid>
    </div>

    <!-- 快捷工具 -->
    <van-cell-group class="mt20" :border="false">
      <van-cell title="快捷工具" class="mt21" />
    </van-cell-group>
    <van-cell title="我的问诊" :icon="require('@/assets/icons/user/tool-01.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
    <van-cell title="我的处方" :icon="require('@/assets/icons/user/tool-02.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
    <van-cell title="家庭档案" :icon="require('@/assets/icons/user/tool-03.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
    <van-cell title="地址管理" :icon="require('@/assets/icons/user/tool-04.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
    <van-cell title="我的评价" :icon="require('@/assets/icons/user/tool-05.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
    <van-cell title="官方客服" :icon="require('@/assets/icons/user/tool-06.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
    <van-cell title="设置" :icon="require('@/assets/icons/user/tool-07.svg')" class="mt22" :border="border">
      <!-- 使用 right-icon 插槽来自定义右侧图标 -->
      <template #right-icon>
        <van-icon name="arrow" class="search-icon" />
      </template>
    </van-cell>
  </div>
</template>

<script>
import { getUserInfo } from '@/api/mypage'
export default {
  name: 'myUser',
  data () {
    return {
      border: false,
      userinfo: {},
      list: []
    }
  },
  created () {
    this.myUser()
  },
  methods: {
    async myUser () {
      const res = await getUserInfo()
      console.log(res)
      this.userinfo = res.data
      this.list = res.data.consultationInfo
    }
  }
}
</script>

<style lang="less" scoped>
.zero{
  font-weight: 600;
}

.views{
   border-radius: 0 0 10px 10px;
   background-color: #fff;
   overflow: hidden;
}
.doctor{
  background-color: #fff;
  margin-top: 10px;
  border-radius: 10px;
  h4{
    padding-left: 15px;
  }
   .my-swipe .van-swipe-item {
    width: 100%;
    padding-bottom:40px ;
    align-items: center;

    .contentbox{
      display: flex;
      align-items: center;
      img{
      margin-left: 10px;
      width: 50px;
      height: 50px;
      border-radius: 50%;
      margin-right: 10px;
    }
    .middle{
      .top{
        .lefttxt{
          font-size: 20px;
          font-weight: 600;
          margin-right: 10px;
        }
        .righttxt{
          font-size: 12px;
          color:#A1A1A1;
        }
      }
      .bottom{
        margin-top: 3px;
        .lefttxt{
          font-size: 11px;
          color: #fff;
          display: inline-block;
          height: 16px;
          text-align: center;
          line-height: 16px;
          margin-right: 5px;
          background-color: #677FFF;
          border-radius: 5px;
        }
        .righttxt{
          height: 16px;
          line-height: 16px;
          color: #66686B;
          font-size: 12px;
        }
      }
    }
    }
    button{
      background-color: #EAF8F6;
      color: #6DCCC1;
      font-size: 12px;
      border: none;
      width: 80px;
      height: 30px;
      border-radius: 15px;
      margin-left: 1px;
    }

  }
}
.van-icon__image{
  width: 20px;
  height: 20px;
  padding-top: 2px;
  margin-right: 10px;
}
.user-page {
  padding: 0 10px 80px 10px;
  background: #f5f5f5;
  height: 100%;
  .mt19 {
    margin-top: 20px;
  }
  .mt20 {
    padding-top: 7px;
    margin-top: 10px;
    font-weight: 800;
    border-radius: 10px 10px 0 0;
    .all {
      font-size: 14px;
      font-weight: 400;
    }
    .mt21 {
      font-size: 17px;
       border-radius: 10px 10px 0 0;
    }
  }
  .mt22 {
    height: 50px;
    &:nth-last-child(1){
       border-radius: 0 0 10px 10px;
    }
    .search-icon {
      margin-top: 4px;
    }
  }
  .user {
    position: relative;
    display: flex;
    margin: 0 -10px;
    align-items: center;
    height: 200px;
    background: linear-gradient(
      180deg,
      rgba(44, 181, 165, 0.46),
      rgba(44, 181, 165, 0)
    );
    img {
      margin-left: 20px;
      width: 70px;
      height: 70px;
      border-radius: 50%;
      overflow: hidden;
    }
    h3 {
      padding-left: 20px;
      margin-bottom: 50px;
      font-size: 18px;
    }
    .edit{
      margin-left: -68px;
      margin-top: 30px;
    }
    .my_list {
      position: absolute;
      left: 20px;
      bottom: 36px;
      display: flex;
      .list {
        text-align: center;
        width: 84px;
        height: 20px;
        .zero {
          margin: 5px;
          font-size: 18px;
        }
        .gray {
          font-size: 12px;
          margin: 0px;
          color: #98999f;
        }
      }
    }
  }
}

</style>
